package com.syni.mdd.yhd.common.all.controller.api.common;

import com.syni.mdd.sjb.common.component.utils.common.utils.ParamsMap;
import com.syni.mdd.sjb.common.component.utils.common.utils.ResultMapHelper;
import com.syni.mdd.sjb.common.component.utils.common.utils.RpcResponseVo;
import com.syni.mdd.yhd.common.all.constants.ResultCode;
import com.syni.mdd.yhd.common.all.constants.ResultMsg;
import com.syni.mdd.yhd.common.all.service.BmsDxConfigService;
import com.syni.mdd.sjb.common.component.utils.feign.service.mddAll.ApiConfigRestService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/apiConfig")
@Log4j2
public class ApiDxConfigRestApi implements ApiConfigRestService{
    @Autowired
    BmsDxConfigService bmsDxConfigService;

    @GetMapping("/getDxshAppConfig")
    public RpcResponseVo getDxshAppConfig(){
        ParamsMap paramsMap = new ParamsMap();
        Map<String,Object> resultMap = bmsDxConfigService.getDxshAppConfig(paramsMap);
        if(ResultMapHelper.isSuccess(resultMap)){
            return RpcResponseVo.success(resultMap.get("data"),ResultMsg.MSG_GET_SUCCESS);
        }
        return RpcResponseVo.result(ResultCode.CODE_ERROR_05,ResultMsg.CODE_ERROR_05);
    }

    @GetMapping("/getConfigInfo")
    public Map<String,Object> getConfigInfo(@RequestParam("code") Integer code){
        return ResultMapHelper.success(bmsDxConfigService.getConfigByCode(code), ResultMsg.MSG_GET_SUCCESS);
    }
}
